#!/bin/bash

# Setup getopt.
long_opts="debug,arg:"
getopt_cmd=$(getopt -o da: --long "$long_opts" \
            -n $(basename $0) -- "$@") || \
            { echo -e "\nERROR: Getopt failed. Extra args\n"; exit 1;}

eval set -- "$getopt_cmd"
while true; do
    case "$1" in
        -d|--debug) echo "debug is true";;
        -a|--arg) echo "arg is $2";;
        --) shift; break;;
    esac
    shift
done